﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using OpenMms.Common.Auth;
using OpenMms.Domain.BLL.User;
using OpenMms.Domain.Interface.User;
using OpenMms.Domain.RequestModels;
using Microsoft.AspNetCore.Mvc;

namespace OpenMms.MVC.Areas.User.Controllers
{
    /// <summary>
    /// 服务中心申请
    /// </summary>
    [Area("User")]
    public class ServiceCenterController :BaseController
    {

        #region 注入
        private IServiceCenterService _service;
        public ServiceCenterController(IAuth auth, IServiceCenterService service) : base(auth)
        {
            this._service = service;
        }
        #endregion


        /// <summary>
        /// 首页
        /// </summary>
        /// <returns></returns>
        public IActionResult Index() => View();

        #region 申请操作
        /// <summary>
        /// 服务中心申请操作
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        [ValidateAntiForgeryToken]
        public async Task<JsonResult> CenterApply(ServiceCenterReq model)
        {
            model.ServiceCenterCode = _auth.GetCurrentUser().Account;
            return Json(await _service.Apply(model));
        }
        #endregion

    }
}